<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<!DOCTYPE html>
<html>

<head>
  <title>襄阳蓝芯智能化办公系统</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="${pageContext.request.contextPath}/static/bootstrap-3.3.5/css/bootstrap.css" rel="stylesheet">
  <style>
    /*定义类名为.thead-blue的样式*/
    .thead-blue {
      color: #fff;
      font-weight: bold;
      background-color: #337ab7;
    }
  </style>
  <script src="${pageContext.request.contextPath}/static/jquery/jquery-1.10.2.min.js"></script>
  <script src="${pageContext.request.contextPath}/static/bootstrap-3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<!-- 搜索 -->
<div class="panel panel-primary">
  <div class="panel-heading">
    <h4 class="panel-title">报销类型搜索</h4>
  </div>
  <div class="panel-body">
    <form action="${pageContext.request.contextPath}/bx-informaltype/toinformaltypelist" id="seachform" method="post" class="form-horizontal" role="form">
      <div class="form-group">
        <div class="col-md-12">
          <label for="type" class="col-md-2 control-label">报销类型名称</label>
          <div class="col-md-4">
            <input type="hidden" name="page" id="page" value="${pageNum}">
            <input type="hidden" name="pageSize" id="pageSize" value="${pageSize}">
            <input type="text" class="form-control" name="name" value="${name}">
          </div>
          <div class="col-md-6">
            <button type="button" onclick="searchBtn()" class="btn btn-success">搜索</button>
            <a type="button" href="${pageContext.request.contextPath}/bx-informaltype/toinformaltypeedit" class="btn btn-info">添加</a>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>


<div class="panel panel-primary">
  <table class="table table-bordered table-hover">
    <thead>
    <tr class="thead-blue" align="center">
      <th>编号</th>
      <th>名称</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${bxInformaltypelist.records}" var="bxlist" varStatus="status">
      <tr align="center">
        <td>${bxlist.oid}</td>
        <td>${bxlist.name}</td>
        <td>${bxlist.isActice == 'Y' ? '可用' : '不可用'}</td>
        <td>
          <button type="button" onclick="location.href='${pageContext.request.contextPath}/bx-informaltype/toinformaltypeedit?oid=${bxlist.oid}'" class="btn btn-warning btn-xs">修改</button>
          <button type="button" onclick="deleteBxInformaltype(${bxlist.oid})" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#confirmModal">删除</button>
        </td>
      </tr>
    </c:forEach>
    </tbody>
  </table>
</div>

<div class="input-group col-md-6 col-md-offset-3">
  <div class="text-center">
    <div class="btn-group">
      <button onclick="gotoPage(1, ${pageSize})" class="btn btn-primary" type="button">首页</button>
      <button onclick="gotoPage(${pageNum - 1}, ${pageSize})" class="btn btn-primary ${pageNum == 1 ? 'disabled' : ''}" type="button">上一页</button>
      <button class="btn btn-primary disabled" type="button">当前第${pageNum}/${totalPages}页</button>
      <div class="btn-group">
        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          每页显示${pageSize}条 <span class="caret"></span>
        </button>
        <ul class="dropdown-menu">
          <li><a href="javascript:gotoPage(1,5)">每页显示5条</a></li>
          <li><a href="javascript:gotoPage(1,10)">每页显示10条</a></li>
          <li><a href="javascript:gotoPage(1,15)">每页显示15条</a></li>
          <li><a href="javascript:gotoPage(1,20)">每页显示20条</a></li>
        </ul>
      </div>
      <button class="btn btn-primary disabled" type="button">共${total}条记录</button>
      <button onclick="gotoPage(${pageNum + 1}, ${pageSize})" class="btn btn-primary ${pageNum == totalPages ? 'disabled' : ''}" type="button">下一页</button>
      <button onclick="gotoPage(${totalPages}, ${pageSize})" class="btn btn-primary" type="button">尾页</button>
    </div>
  </div>
</div>

<br><br><br>



<!-- 模态框（Modal） -->
<div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="confirmModalLabel">
          提示
        </h4>
      </div>
      <div class="modal-body">
        确认删除吗？
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
        <button type="button" id="subconfirm" class="btn btn-primary">
          提交更改
        </button>
      </div>
    </div>
  </div>
</div>
<script>
  $(document).ready(function(){
    $("#subconfirm").click(function(){
      deleteConfirm();
      $('#confirmModal').modal('hide');
    });
  });
</script>


<!-- 模态框（Modal） -->
<div class="modal fade" id="alertMsgModal" tabindex="-1" role="dialog" aria-labelledby="alertMsgModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-xs">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="alertMsgModalLabel">
          提示
        </h4>
      </div>
      <div class="modal-body" id="alertmsg">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>






<script type="text/javascript">
  $(document).ajaxError(function(event,xhr) {
    if(xhr.status=="403"){//没有权限
      document.location.href = xhr.getResponseHeader("url");
    }else if(xhr.status!="200"){
      //alert("服务器错误!");
      console.log("服务器错误!");
    }
  });
</script>

</body>
<script type="text/javascript">
  function gotoPage(page,pageSize){
    $("#page").val(page);
    $("#pageSize").val(pageSize);
    $("#seachform").submit();
  }
  function searchBtn(){
    $("#page").val(1);
    $("#seachform").submit();
  }
  var deleteoid;
  function deleteBxInformaltype(oid){
    deleteoid = oid;
  }

  function deleteConfirm(){
    $.get("${pageContext.request.contextPath}/bx-informaltype/toinformaltypedelete",{"oid":deleteoid},function(s){
      if(s==true){
        document.location.href="${pageContext.request.contextPath}/bx-informaltype/toinformaltypelist";
      }else{
        $("#alertmsg").text("删除失败,当前报销类别正在使用!");
        $('#alertMsgModal').modal('show');
      }
    });
  }
</script>
</html>